package com.google.code.dajly.model;

import java.io.Serializable;
import java.net.URL;
import java.util.Date;

/** Classe che rappresenta una Entry in un Feed 
 * @author stefano pigozzi*/
public class Entry implements Serializable, Cloneable{

	private static final long serialVersionUID = 1L;
	
	private String title;
	private String message;
	private String author;
	private URL fullStoryURL;
	private Date publishedDate;
	
	/***Costruisce la Entry
	 * @param title [String]: titolo
	 * @param message [String]: messaggio
	 * @param author [String]: autore
	 * @param fullStoryURL [URL]: link alla storia
	 * @param publishedDate [Date]: Data pubblicazione*/
	protected Entry(String title, String message, String author, URL fullStoryURL, Date publishedDate){
		if(title != null)
			this.title = title;
		else this.title = new String("");
		
		if(message != null)
			this.message = message;
		else this.message = new String("");
		
		if(author != null)
			this.author = author;
		else this.author = new String("");
		
		this.fullStoryURL = fullStoryURL;
		this.publishedDate = publishedDate;
	}
	
	/***@return titolo*/
	public String getTitle(){
		return this.title;
	}
	/***@return messaggio*/
	public String getMessage(){
		return this.message;
	}
	
	/***@return autore*/
	public String getAuthor(){
		return this.author;
	}
	
	/***@return fullstoryurl*/
	public URL getStoryURL(){
		return this.fullStoryURL;
	}
	
	/***@return data pubblicazione*/
	public Date getPublishedDate(){
		return this.publishedDate;
	}
	
	public boolean equals(Object obj){
		if(! (obj instanceof Entry))
			return false;
		else return this.equals((Entry)obj);
	}

	/***Verifica uguaglianza
	 * @param e [Entry]: oggetto su cui verificare uguaglianza
	 * @return titolo messaggio e autore sono uguali?*/
	public boolean equals(Entry e){
		if( (e.title.equals(this.title)) &&
			(e.message.equals(this.message)) &&
		    (e.author.equals(this.author)))
			return true;
		else
			return false;
		
	}
	
	
}
